fix: Filter out disabled AI Agent tool parents when mapping connected tools#28743
fix: Filter out disabled AI Agent tool parents when mapping connected tools#28743Dom-Tursini wants to merge 1 commit into
Conversation
9f32c74 to
7a6d889
Compare
There was a problem hiding this comment.
No issues found across 2 files
Architecture diagram
sequenceDiagram
participant Agent as AI Agent Node
participant Helper as getConnectedTools()
participant Context as n8n Workflow Context
Note over Agent,Context: Tool Connection Mapping Flow
Agent->>Helper: Invoke tool resolution
Helper->>Context: getInputConnectionData(AiTool)
Context-->>Helper: toolkitConnections (Active tool objects)
Helper->>Context: getParentNodes(currentNode, AiTool)
Context-->>Helper: parentNodes (All connected nodes)
rect rgb(240, 240, 240)
Note over Helper: Fix: Prevent index desync
Helper->>Helper: NEW: Filter out nodes where disabled === true
end
loop For each tool in toolkitConnections
Helper->>Helper: CHANGED: Map tool to parentNode by matching index
Note right of Helper: Correlation relies on identical list lengths
end
Helper-->>Agent: Return tools with correct sourceNodeName metadata
7a6d889 to
ec053b8
Compare
d0bef14 to
08bee6d
Compare
e3eeddb to
2fbfe35
Compare
86472c8 to
66b1602
Compare
66b1602 to
4759491
Compare
|
Closing this as the fix has been merged via #29460 by @schrothbn . I’m glad to see the index-desync I identified here was resolved using the same logic. Hopefully, the regression tests I included here can still be useful for the core team. |
|
Leaving this here for provenance/context. This PR originally contained the same fix that later shipped via #29460 filtering disabled AI tool nodes out of parentNodes so the parentNodes/toolkitConnections indexes stay aligned. After rebasing onto master, the diff no longer shows that line because the same change had already been merged via #29460 . I understand this may have been handled through internal tracking, so I just wanted to record the connection between the two PRs for future context. |
Summary
This fixes a tool/source-node desync in getConnectedTools() for AI Agent tool connections when disabled AI tool nodes remain connected.
Previously,
toolkitConnectionsexcluded disabled AI tool nodes, whileparentNodesstill included them. Because the helper correlates both arrays by index, disabling any AI tool node caused later tools to receive the wrongsourceNodeName.This change filters disabled nodes out of
parentNodesso both arrays use the same active-node set and stay index-aligned.A regression test was added to cover the case where a disabled tool node appears between active tool connections.
How to test:
sourceNodeName.pnpm test -- utils/tests/helpers.test.ts --runInBandinpackages/@n8n/nodes-langchain.Related Linear tickets, Github issues, and Community forum posts
#26356
Review / Merge checklist
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)